<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./myPromise.js"></script>
  <script>
    var p1 = new MyPromise((resolve, reject) => {
      resolve(1)
    })

    var p2 = new MyPromise((resolve, reject) => {
      resolve(2)
    })
    // eg1
    // let p3 = p1.then((value) => {
    //   console.log(value)
    //   return p3
    // })

    // p3.then((r) => {
    //   console.log(r)
    // }, (reason) => {
    //   console.log(reason)  //可接收到错误
    // })


    // eg2
    let p3 = p1
      .then((value) => {
        console.log(value)
        return p3
      })
      .then(() => { console.log('111') }, (reason) => {
        //接收不到错误
        console.log(reason)
      })

  </script>
</body>
</html>